#include <math.h>
#include "math_hack.h"

float _COS(float rad)
{
    return cos(rad);
}

float _SIN(float rad)
{
    return sin(rad);
}

float _TAN(float rad)
{
    return tan(rad);
}

float _SQRT(float x)
{
    float xhalf = 0.5f * x;
    long i = *(long*) & x; // get bits for floating value
    i = 0x5f375a86 - (i >> 1); // gives initial guess y0
    x = *(float*) & i; // convert bits back to float
    x = x * (1.5f - xhalf * x * x); // Newton step, repeating increases accuracy
    x = x * (1.5f - xhalf * x * x); // Newton step, repeating increases accuracy
    return 1.0 / x;
}

float _POW(float base, float exp)
{
    return pow(base, exp);
}
